<script setup lang="ts">
import { ref } from 'vue'

// 维护信息
const maintenanceInfo = {
  title: '系统维护中',
  description: '我们正在进行系统升级，以提供更好的服务体验。',
  estimatedTime: '预计维护时间：2小时',
  startTime: '2024-03-20 22:00',
  endTime: '2024-03-21 00:00'
}

// 倒计时
const countdown = ref({
  hours: 2,
  minutes: 0,
  seconds: 0
})

// 更新倒计时
const updateCountdown = () => {
  const now = new Date()
  const end = new Date(maintenanceInfo.endTime)
  const diff = end.getTime() - now.getTime()

  if (diff <= 0) {
    countdown.value = {
      hours: 0,
      minutes: 0,
      seconds: 0
    }
    return
  }

  const hours = Math.floor(diff / (1000 * 60 * 60))
  const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60))
  const seconds = Math.floor((diff % (1000 * 60)) / 1000)

  countdown.value = {
    hours,
    minutes,
    seconds
  }
}

// 启动倒计时
setInterval(updateCountdown, 1000)
updateCountdown()
</script>

<template>
  <div class="maintenance">
    <div class="maintenance-container">
      <div class="maintenance-icon">🔧</div>
      <h1>{{ maintenanceInfo.title }}</h1>
      <p class="description">{{ maintenanceInfo.description }}</p>
      <p class="estimated-time">{{ maintenanceInfo.estimatedTime }}</p>

      <div class="countdown">
        <div class="countdown-item">
          <span class="countdown-value">{{ countdown.hours }}</span>
          <span class="countdown-label">小时</span>
        </div>
        <div class="countdown-separator">:</div>
        <div class="countdown-item">
          <span class="countdown-value">{{ countdown.minutes }}</span>
          <span class="countdown-label">分钟</span>
        </div>
        <div class="countdown-separator">:</div>
        <div class="countdown-item">
          <span class="countdown-value">{{ countdown.seconds }}</span>
          <span class="countdown-label">秒</span>
        </div>
      </div>

      <div class="maintenance-time">
        <p>开始时间：{{ maintenanceInfo.startTime }}</p>
        <p>结束时间：{{ maintenanceInfo.endTime }}</p>
      </div>

      <div class="maintenance-notice">
        <h2>维护内容</h2>
        <ul>
          <li>系统性能优化</li>
          <li>安全更新</li>
          <li>新功能部署</li>
          <li>数据库维护</li>
        </ul>
      </div>

      <div class="maintenance-contact">
        <p>如有紧急问题，请联系：</p>
        <a href="mailto:support@example.com">support@example.com</a>
      </div>
    </div>
  </div>
</template>

<style scoped>
.maintenance {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 2rem;
}

.maintenance-container {
  text-align: center;
  max-width: 600px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 3rem 2rem;
}

.maintenance-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 1rem;
}

.description {
  color: #666;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.estimated-time {
  color: #007bff;
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 2rem;
}

.countdown {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2rem;
}

.countdown-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.countdown-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: #007bff;
  line-height: 1;
}

.countdown-label {
  font-size: 0.875rem;
  color: #666;
  margin-top: 0.5rem;
}

.countdown-separator {
  font-size: 2.5rem;
  font-weight: 700;
  color: #007bff;
  margin: 0 0.5rem;
  padding-bottom: 1.5rem;
}

.maintenance-time {
  margin-bottom: 2rem;
  color: #666;
}

.maintenance-time p {
  margin: 0.5rem 0;
}

.maintenance-notice {
  margin-bottom: 2rem;
  text-align: left;
}

.maintenance-notice h2 {
  font-size: 1.25rem;
  color: #333;
  margin-bottom: 1rem;
}

.maintenance-notice ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.maintenance-notice li {
  color: #666;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  position: relative;
}

.maintenance-notice li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #007bff;
}

.maintenance-contact {
  color: #666;
}

.maintenance-contact a {
  color: #007bff;
  text-decoration: none;
}

.maintenance-contact a:hover {
  text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .maintenance-container {
    padding: 2rem 1.5rem;
  }

  .maintenance-icon {
    font-size: 3rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .description,
  .estimated-time {
    font-size: 1rem;
  }

  .countdown-value {
    font-size: 2rem;
  }

  .countdown-separator {
    font-size: 2rem;
  }
}
</style> 